﻿using InnoWeb.CEND.BL.Infrastructure;
using InnoWeb.CEND.Core.Model.General;
using InnoWeb.CEND.Data;
using InnoWeb.CEND.Data.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InnoWeb.CEND.BL.Service
{
    public class MottoService: IService<MottoItem>
    {
        private readonly GenericRepository<MottoItem> _mottoRepository;
        private readonly IUnitOfWork _unitOfWork;

        public MottoService(IUnitOfWork unitOfWork, GenericRepository<MottoItem> mottoRepository)
        {
            this._mottoRepository = mottoRepository;
            this._unitOfWork = unitOfWork;
        }


        public IQueryable<MottoItem> GetAllElements()
        {
            return _mottoRepository.GetAll();
        }

        public MottoItem GetElementById(int id)
        {
            return _mottoRepository.GetById(id);
        }

        public void CreateElement(MottoItem entity)
        {
            _mottoRepository.Insert(entity);
        }

        public void UpdateElement(MottoItem entity)
        {
            _mottoRepository.Update(entity);
        }

        public void DeleteElement(int id)
        {
            _mottoRepository.Delete(id);
        }

        public void SaveChanges()
        {
            _unitOfWork.SaveChanges();
        }
    }
}
